#ifndef LINEAR_CG_STATE_H
#define LINEAR_CG_STATE_H

#include "PArray.h"
#include "IterationState.h"

class DeformationState;
class FiniteElementModel;

class LinearCGState : public IterationState
{
public:
	Real residual_tolerance_;

	Array<Real> search_dir_;
	Array<Real> mat_times_search_dir_;
	Array<Real> residual_;

	Real residual_len_;
	Real prev_residual_len_;

	LinearCGState ();

	void CGIterationStep (Real*,
		bool const*,
		void*,
		void (*)(void*, Real*,Real const*));
	void CGReinit ();

	LinkArray< Array<Real> > VectorVariables ();
	virtual void IterationStep(DeformationState *);
	virtual void UpdateResidual (DeformationState const*);
	virtual int RelaxationCount (FiniteElementModel*)const;
	virtual void PrintNodes () const;
	virtual void Print () const;
	virtual bool GoodSolution (DeformationState const*) const;
	bool CGGoodSolution (Real) const;
	virtual void Reinit (DeformationState const*);
protected:

};

#endif /* LINEAR-CG_STATE_H */